# !/usr/bin/env python
from fastapi import FastAPI
from langserve import add_routes
from lcel_rag import *
from lcel import *
import uvicorn

app = FastAPI(
    title="LangChain Server",
    version="1.0",
    description="A simple api server using Langchain's Runnable interfaces",
)

model = get_llm()

prompt = ChatPromptTemplate.from_template("讲一个关于{topic}的笑话")

add_routes(
    app,
    prompt | model,
    path="/joke",
)

add_routes(
    app,
    rag_chain,
    path="/rag",
)

add_routes(
    app,
    runnable,
    path="/lcel",
)

if __name__ == "__main__":
    uvicorn.run(app, host="127.0.0.1", port=8889)
